
interface stateType {
    pTitle: string,
    pNum: number,
    dataList: any[]
}


interface actionType {
    type: string,
    data?: any
}

const PositionState =  {
    pTitle: '1906A position title',
    pNum: 1,
    dataList: []
}

const positionReducer = (state:stateType = PositionState, action:actionType) => {
    const { type } = action

    if (type === 'CHANGE_P_TITLE') {
        return {
            ...state,
            pTitle: action.data
        }
    }

    if (type  === 'CHANGE_DATA_LIST') {
        return {
            ...state,
            dataList: action.data
        }
    }

    return state
}

export default positionReducer